package neusoft.yuejian_11.adapter;

import android.content.Context;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.MediaController;

import java.util.List;

import neusoft.yuejian_11.base.BaseListAdapter;
import neusoft.yuejian_11.bean.MasterVideoBean;
import neusoft.yuejian_11.R;
import neusoft.yuejian_11.viewHolder.MasterVedioViewHolder;

import static neusoft.yuejian_11.interF.Const.BASE_URI;

/**
 * Created by NEUSOFT on 2017/10/26.
 */

public class MasterVideoAdapter extends BaseListAdapter {
    public MasterVideoAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView=layoutInflater.inflate(R.layout.item_mastervedio,parent,false);
        MasterVedioViewHolder holder=new MasterVedioViewHolder(itemView);
        return holder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        MasterVedioViewHolder masterVedioViewHolder=(MasterVedioViewHolder) holder;
        final MasterVideoBean masterVideoBean = (MasterVideoBean)data.get(position);
        final String mastervideoname =masterVideoBean.getMv_name();
        masterVedioViewHolder.MasterVideoNameView.setText(mastervideoname);
        Uri uri=Uri.parse(BASE_URI+"videoMp4/"+masterVideoBean.getMv_address());
        masterVedioViewHolder.MasterVideoView.setMediaController(new MediaController(context));
        masterVedioViewHolder.MasterVideoView.setVideoURI(uri);
    }


}
